package com.yellowpage.bigdata.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.yellowpage.white.common.Constants;
import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;

import com.yellowpage.bigdata.data.TmApponoffNewUserMonthEntity;
import com.yellowpage.bigdata.dao.TmApponoffNewUserMonthEntityDao;

public class TmApponoffNewUserMonthEntityServiceImpl extends BaseServiceImpl implements TmApponoffNewUserMonthEntityService {
	  private TmApponoffNewUserMonthEntityDao tmApponoffNewUserMonthEntityDao;
	
	  public void setTmApponoffNewUserMonthEntityDao(TmApponoffNewUserMonthEntityDao tmApponoffNewUserMonthEntityDao) {
		  this.tmApponoffNewUserMonthEntityDao = tmApponoffNewUserMonthEntityDao;
	  }
	
	
	  /* Smooth generate Method */ 
	  public TmApponoffNewUserMonthEntity getTmApponoffNewUserMonthEntity(Long id){
	      return tmApponoffNewUserMonthEntityDao.get(id);
	  }
	  
    public List<TmApponoffNewUserMonthEntity> getAllTmApponoffNewUserMonthEntity(){
        return tmApponoffNewUserMonthEntityDao.getAll();
    }
    
    public List<Map> queryTmApponoffNewUserMonthEntityByPage(Map queryMap, PageRender pageRender) {		
        
		QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(
				"SELECT a.TM_APPONOFF_NEW_USER_MONTH_ID , a.AREACODE , a.OPERATOR , a.CHANNELNO , a.UV_IMEI , a.CREATE_TIME , a.MONTH_ID    FROM tm_apponoff_new_user_month a WHERE 1=1 ")
				    			.addCondition(" and TM_APPONOFF_NEW_USER_MONTH_ID = :tmApponoffNewUserMonthId ")
							    			.addCondition(" and AREACODE = :areacode ")
							    			.addCondition(" and OPERATOR = :operator ")
							    			.addCondition(" and CHANNELNO = :channelno ")
							    			.addCondition(" and UV_IMEI = :uvImei ")
							    		    .addCondition(" and date_format(CREATE_TIME,'%Y-%m-%d') =  :createTime  ")
		    				    			.addCondition(" and MONTH_ID = :monthId ")
							    ; 		    
		    

		List<Map> resultList = sqlAssistant.queryByPage(
				baseDao.getConnection(), queryMap, pageRender);

		return resultList;
	}
    
    
    public void saveTmApponoffNewUserMonthEntity(TmApponoffNewUserMonthEntity tmApponoffNewUserMonthEntity){
        tmApponoffNewUserMonthEntityDao.save(tmApponoffNewUserMonthEntity);
    }
    
	  public void updateTmApponoffNewUserMonthEntity(TmApponoffNewUserMonthEntity tmApponoffNewUserMonthEntity){
	      tmApponoffNewUserMonthEntityDao.update(tmApponoffNewUserMonthEntity);
	  }
	  
	  public void delete(List deleteList){
	      tmApponoffNewUserMonthEntityDao.remove(deleteList);
	  }
	  
	  
	 
	
}	